package 蓝桥算法.A01;

import java.util.Arrays;

public class  斐波那契数列 {
    public static void main(String[] args){
        //不死神兔
        //[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]
        //求解1:
        int[] arr = new int[12];
        arr[0] = 1;
        arr[1] = 1;
        for (int i = 2; i < arr.length; i++) {
            arr[i] = arr[i-1] + arr[i-2];
        }
        System.out.println(Arrays.toString(arr));

        //求解2:
        System.out.println(fn(12));
    }
    private static int fn(int month){
        if (month == 1 || month == 2){
            return 1;
        }
        return fn(month - 1) + fn(month -2);
    }
}
